home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / play / sparctracker100.lha / SparcTracker / audio_device.h next >
C/C++ Source or Header  |  1992-10-28  |  7KB  |  183 lines

  1. /*    @(#)audio_device.h 1.1 89/12/22 SMI    */
  2. /* Copyright (c) 1989 by Sun Microsystems, Inc. */
  3.  
  4. #ifndef _multimedia_audio_io_h
  5. #define    _multimedia_audio_io_h
  6.  
  7. #include <sun/audioio.h>
  8.  
  9. typedef audio_info_t    Audio_info;
  10.  
  11. /*
  12.  * The following macros read the current audio device configuration
  13.  * and convert the data encoding format into an Audio_hdr.
  14.  * 'F' is an open audio file descriptor.
  15.  * 'H' is a pointer to an Audio_hdr.
  16.  * The structure '*H' is updated after the device state has been read.
  17.  */
  18. #define    audio_get_play_config(F, H)                    \
  19.         audio__setplayhdr((F), (H), AUDIO__PLAY)
  20. #define    audio_get_record_config(F, H)                    \
  21.         audio__setplayhdr((F), (H), AUDIO__RECORD)
  22.  
  23. /*
  24.  * The following macros attempt to reconfigure the audio device so that
  25.  * it operates on data encoded according to a given Audio_hdr.
  26.  * 'F' is an open audio file descriptor.
  27.  * 'H' is a pointer to an Audio_hdr describing the desired encoding.
  28.  * The structure '*H' is updated after the device state has been read
  29.  * to reflect the actual state of the device.
  30.  *
  31.  * AUDIO_SUCCESS is returned if the device configuration matches the
  32.  * requested encoding.  AUDIO_ERR_NOEFFECT is returned if it does not.
  33.  */
  34. #define    audio_set_play_config(F, H)                    \
  35.         audio__setplayhdr((F), (H), AUDIO__SET|AUDIO__PLAY)
  36. #define    audio_set_record_config(F, H)                    \
  37.         audio__setplayhdr((F), (H), AUDIO__SET|AUDIO__RECORD)
  38.  
  39.  
  40. /*
  41.  * The following macros pause or resume the audio play and/or record channels.
  42.  * Note that requests to pause a channel that is not open will have no effect.
  43.  * In such cases, AUDIO_ERR_NOEFFECT is returned.
  44.  */
  45. #define    audio_pause(F)                            \
  46.         audio__setpause((F), AUDIO__PLAYREC|AUDIO__PAUSE)
  47. #define    audio_pause_play(F)                        \
  48.         audio__setpause((F), AUDIO__PLAY|AUDIO__PAUSE)
  49. #define    audio_pause_record(F)                        \
  50.         audio__setpause((F), AUDIO__RECORD|AUDIO__PAUSE)
  51.  
  52. #define    audio_resume(F)                            \
  53.         audio__setpause((F), AUDIO__PLAYREC|AUDIO__RESUME)
  54. #define    audio_resume_play(F)                        \
  55.         audio__setpause((F), AUDIO__PLAY|AUDIO__RESUME)
  56. #define    audio_resume_record(F)                        \
  57.         audio__setpause((F), AUDIO__RECORD|AUDIO__RESUME)
  58.  
  59.  
  60. /*
  61.  * The following macros get individual state values.
  62.  * 'F' is an open audio file descriptor.
  63.  * 'V' is a pointer to an unsigned int.
  64.  * The value '*V' is updated after the device state has been read.
  65.  */
  66. #define    audio_get_play_port(F, V)                    \
  67.         audio__setval((F), (V), AUDIO__PLAY|AUDIO__PORT)
  68. #define    audio_get_record_port(F, V)                    \
  69.         audio__setval((F), (V), AUDIO__RECORD|AUDIO__PORT)
  70. #define    audio_get_play_samples(F, V)                    \
  71.         audio__setval((F), (V), AUDIO__PLAY|AUDIO__SAMPLES)
  72. #define    audio_get_record_samples(F, V)                    \
  73.         audio__setval((F), (V), AUDIO__RECORD|AUDIO__SAMPLES)
  74. #define    audio_get_play_error(F, V)                    \
  75.         audio__setval((F), (V), AUDIO__PLAY|AUDIO__ERROR)
  76. #define    audio_get_record_error(F, V)                    \
  77.         audio__setval((F), (V), AUDIO__RECORD|AUDIO__ERROR)
  78. #define    audio_get_play_eof(F, V)                    \
  79.         audio__setval((F), (V), AUDIO__PLAY|AUDIO__EOF)
  80.  
  81. #define    audio_get_play_open(F, V)                    \
  82.         audio__setval((F), (V), AUDIO__PLAY|AUDIO__OPEN)
  83. #define    audio_get_record_open(F, V)                    \
  84.         audio__setval((F), (V), AUDIO__RECORD|AUDIO__OPEN)
  85. #define    audio_get_play_active(F, V)                    \
  86.         audio__setval((F), (V), AUDIO__PLAY|AUDIO__ACTIVE)
  87. #define    audio_get_record_active(F, V)                    \
  88.         audio__setval((F), (V), AUDIO__RECORD|AUDIO__ACTIVE)
  89. #define    audio_get_play_waiting(F, V)                    \
  90.         audio__setval((F), (V), AUDIO__PLAY|AUDIO__WAITING)
  91. #define    audio_get_record_waiting(F, V)                    \
  92.         audio__setval((F), (V), AUDIO__RECORD|AUDIO__WAITING)
  93.  
  94.  
  95. /*
  96.  * The following macros set individual state values.
  97.  * 'F' is an open audio file descriptor.
  98.  * 'V' is a pointer to an unsigned int.
  99.  * The value '*V' is updated after the device state has been read.
  100.  */
  101. #define    audio_set_play_port(F, V)                    \
  102.         audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__PORT)
  103. #define    audio_set_record_port(F, V)                    \
  104.         audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__PORT)
  105.  
  106. /*
  107.  * The value returned for these is the value *before* the state was changed.
  108.  * This allows you to atomically read and reset their values.
  109.  */
  110. #define    audio_set_play_samples(F, V)                    \
  111.         audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__SAMPLES)
  112. #define    audio_set_record_samples(F, V)                    \
  113.         audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__SAMPLES)
  114. #define    audio_set_play_error(F, V)                    \
  115.         audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__ERROR)
  116. #define    audio_set_record_error(F, V)                    \
  117.         audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__ERROR)
  118. #define    audio_set_play_eof(F, V)                    \
  119.         audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__EOF)
  120.  
  121. /* The value can only be set to one.  It is reset to zero on close(). */
  122. #define    audio_set_play_waiting(F, V)                    \
  123.         audio__setval((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__WAITING)
  124. #define    audio_set_record_waiting(F, V)                    \
  125.         audio__setval((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__WAITING)
  126.  
  127.  
  128. /*
  129.  * Gain routines take double values, mapping the valid range of gains
  130.  * to a floating-point value between zero and one, inclusive.
  131.  * The value returned will likely be slightly different than the value set.
  132.  * This is because the value is quantized by the device.
  133.  *
  134.  * Make sure that 'V' is a (double *)!
  135.  */
  136. #define    audio_get_play_gain(F, V)                    \
  137.         audio__setgain((F), (V), AUDIO__PLAY|AUDIO__GAIN)
  138. #define    audio_get_record_gain(F, V)                    \
  139.         audio__setgain((F), (V), AUDIO__RECORD|AUDIO__GAIN)
  140. #define    audio_get_monitor_gain(F, V)                    \
  141.         audio__setgain((F), (V), AUDIO__MONGAIN)
  142.  
  143. #define    audio_set_play_gain(F, V)                    \
  144.         audio__setgain((F), (V), AUDIO__SET|AUDIO__PLAY|AUDIO__GAIN)
  145. #define    audio_set_record_gain(F, V)                    \
  146.         audio__setgain((F), (V), AUDIO__SET|AUDIO__RECORD|AUDIO__GAIN)
  147. #define    audio_set_monitor_gain(F, V)                    \
  148.         audio__setgain((F), (V), AUDIO__SET|AUDIO__MONGAIN)
  149.  
  150. /*
  151.  * The following macros flush the audio play and/or record queues.
  152.  * Note that requests to flush a channel that is not open will have no effect.
  153.  */
  154. #define    audio_flush(F)                            \
  155.         audio__flush((F), AUDIO__PLAYREC)
  156. #define    audio_flush_play(F)                        \
  157.         audio__flush((F), AUDIO__PLAY)
  158. #define    audio_flush_record(F)                        \
  159.         audio__flush((F), AUDIO__RECORD)
  160.  
  161.  
  162. /* The following is used for 'which' arguments to get/set info routines */
  163. #define    AUDIO__PLAY        (0x10000)
  164. #define    AUDIO__RECORD        (0x20000)
  165. #define    AUDIO__PLAYREC        (AUDIO__PLAY | AUDIO__RECORD)
  166.  
  167. #define    AUDIO__PORT        (1)
  168. #define    AUDIO__SAMPLES        (2)
  169. #define    AUDIO__ERROR        (3)
  170. #define    AUDIO__EOF        (4)
  171. #define    AUDIO__OPEN        (5)
  172. #define    AUDIO__ACTIVE        (6)
  173. #define    AUDIO__WAITING        (7)
  174. #define    AUDIO__GAIN        (8)
  175. #define    AUDIO__MONGAIN        (9)
  176. #define    AUDIO__PAUSE        (10)
  177. #define    AUDIO__RESUME        (11)
  178.  
  179. #define    AUDIO__SET        (0x80000000)
  180. #define    AUDIO__SETVAL_MASK    (0xff)
  181.  
  182. #endif /*!_multimedia_audio_io_h*/
  183.